﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;

namespace WebService2
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://www.aspnetmania.com/webservices/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "YES, IT WORKS!";
        }

        [WebMethod]
        public string HelloWorld_param(string param)
        {
            return  "YES, IT WORKS!" + param;
        }

        [WebMethod]
        public DataSet From_Database(string param)
        {
            SqlConnection sqlconn = new SqlConnection("Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True");
            SqlDataAdapter da = new SqlDataAdapter("_TestProc", sqlconn);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.SelectCommand.Parameters.Add(new SqlParameter("@str_para", SqlDbType.Char, 10));
            da.SelectCommand.Parameters[0].Value=param;

            DataSet ds = new DataSet();
            da.Fill(ds);
            ds.Tables[0].TableName = "MyTable1_";
            ds.Tables[1].TableName = "MyTable2_";

            return ds;

            
        }
    }
}